package com.loongtech.bi.manager.system;

import com.loongtech.bi.support.SpringContextUtil;
import com.loongtech.bi.synch.MonitorMailManager;
import com.loongtech.core.util.Time;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

@DisallowConcurrentExecution
public class DailyReportJobFactory implements Job {

    private MonitorMailManager monitorMailManager = SpringContextUtil.getBean(MonitorMailManager.class);
    /**
     * Author: yuri
     * Description: 执行监控
     * Date: 16:25 2016/11/7
     */
    public void execute(JobExecutionContext context) throws JobExecutionException {
        String job = context.getMergedJobDataMap().getKeys()[0];
        if (null == job) {
            System.out.println("[每日报表]--------------------- 任务为null,返回不执行 ---------------------");
            return;
        }
        System.out.println("[每日报表]--------------------- 监控Id为：" + job + "的任务开始扫描 " + Time.getNowDateDetailStr() + "---------------------");
        monitorMailManager.mail();
        System.out.println("[每日报表]--------------------- 监控Id为：" + job + "的扫描结束 " + Time.getNowDateDetailStr() + "---------------------");
    }
}